<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:pe="http://primefaces.org/ui/extensions"
      xmlns:hr="http://java.sun.com/jsf/composite/autocomplete"
      xmlns:salary="http://java.sun.com/jsf/composite/hr">

    <h:body>

        <ui:composition template="/resources/template/template.xhtml">

            <ui:define name="content">
                <h:form >
                    <p:panel >
                        <f:facet name="header" >
                            <h:outputLabel value="Staff Salary Component" />
                        </f:facet>
                        <h:panelGrid columns="2" >
                            <h:outputLabel value="Salary Cycle"/>
                            <p:selectOneMenu value="#{hrReportController.reportKeyWord.salaryCycle}" 
                                             var="t">
                                <f:selectItem itemLabel="Select Salary Cycle" />    
                                <f:selectItems value="#{salaryCycleController.salaryCycles}" 
                                               var="theme" 
                                               itemLabel="#{theme.name}" 
                                               itemValue="#{theme}" ></f:selectItems>

                                <p:column style="width:10%" headerText="Name">
                                    <h:outputText value="#{t.name}" />
                                </p:column>

                                <p:column headerText="Year">
                                    <h:outputText value="#{t.salaryYear}" />
                                </p:column>
                                <p:column headerText="Month">
                                    <h:outputText value="#{t.salaryMonth}" />
                                </p:column>
                            </p:selectOneMenu>
                            <h:outputLabel value="Institution : "/>
                            <hr:institution value="#{hrReportController.reportKeyWord.institution}"/>                           
                            <h:outputLabel value="Department : "/>
                            <hr:department value="#{hrReportController.reportKeyWord.department}"/>
                            <h:outputLabel value="Employee : "/>
                            <hr:completeStaff value="#{hrReportController.reportKeyWord.staff}"/>
                            <h:outputLabel value="Staff Category : "/>
                            <hr:completeStaffCategory value="#{hrReportController.reportKeyWord.staffCategory}"/>
                            <h:outputLabel value="Staff Designation : "/>
                            <hr:completeDesignation value="#{hrReportController.reportKeyWord.designation}"/>
                            <h:outputLabel value="Staff Roster : "/>
                            <hr:completeRoster value="#{hrReportController.reportKeyWord.roster}"/>
                            <h:outputLabel value="Staff Paysheet Componet : "/>
                            <hr:completePaySheetComponent value="#{hrReportController.reportKeyWord.paysheetComponent}"/>
                            <h:outputLabel value="Bank : "/>
                            <hr:completeBank value="#{hrReportController.reportKeyWord.institutionBank}"/>
                            <h:outputLabel value="Adjested Components"/>
                            <p:selectBooleanCheckbox value="#{hrReportController.reportKeyWord.bool1}" />
                        </h:panelGrid>

                        <p:commandButton ajax="false" value="Process" action="#{hrReportController.createStaffSalaryComponent()}"/>
                        <p:commandButton ajax="false" value="Process Special" action="#{hrReportController.createStaffSalaryComponentSpecial()}"/>

                        <p:commandButton ajax="false" value="Excel" styleClass="noPrintButton" onclick="onSubmitButton();" >
                            <pe:exporter type="xlsx" target="tb1" fileName="staff_salary_component"/>
                        </p:commandButton>
                        <p:commandButton value="Print" ajax="false" action="#">
                            <p:printer target="gpBillPreview"></p:printer>
                        </p:commandButton>
                        <p:panel id="gpBillPreview" styleClass="noBorder summeryBorder" >                     
                            <p:dataTable id="tb1" value="#{hrReportController.staffSalaryComponants}" var="ss">
                                <f:facet name="header">
                                    
                                    <h:outputLabel value="Staff Salary Component"/>
                                    <br/>
                                    <h:outputLabel value="Salary Cycle : #{hrReportController.reportKeyWord.salaryCycle.name}"/>
                                    <br/>
                                    <h:outputLabel value="SC Cycle : " />
                                    <h:outputLabel value="#{hrReportController.reportKeyWord.salaryCycle.workedFromDate}" >
                                        <f:convertDateTime pattern="yyyy MMM dd hh:mm:ss a" />
                                    </h:outputLabel>
                                    <h:outputLabel value="#{hrReportController.reportKeyWord.salaryCycle.workedToDate}"  >
                                        <f:convertDateTime pattern="yyyy MMM dd hh:mm:ss a" />
                                    </h:outputLabel>
                                    <br/>
                                    <h:panelGroup rendered="#{hrReportController.reportKeyWord.institution ne null}" >
                                        <h:outputLabel value="Institution : #{hrReportController.reportKeyWord.institution.name}"/>
                                        <br/>
                                    </h:panelGroup>
                                    <h:panelGroup rendered="#{hrReportController.reportKeyWord.department ne null}" >
                                        <h:outputLabel value="Department : #{hrReportController.reportKeyWord.department.name}"/>
                                        <br/>
                                    </h:panelGroup>
                                    <h:panelGroup rendered="#{hrReportController.reportKeyWord.staff.person.name ne null}" >
                                        <h:outputLabel value="Staff : #{hrReportController.reportKeyWord.staff.person.name}"/>
                                        <br/>
                                    </h:panelGroup>
                                </f:facet>
                                <p:column headerText="Emp No">
                                    <f:facet name="header">         
                                        <h:outputLabel value="Emp No"  />
                                    </f:facet>
                                    <p:outputLabel value="#{ss.staffSalary.staff.codeInterger}" >
                                    </p:outputLabel>
                                </p:column>
                                <p:column headerText="Emp Name" style="text-wrap: avoid; text-overflow: clip; white-space: nowrap;">
                                    <f:facet name="header">
                                        <h:outputLabel value="Emp Name"/>
                                    </f:facet>
                                    <p:outputLabel value="#{ss.staffSalary.staff.person.nameWithTitle}">
                                    </p:outputLabel>
                                </p:column>                              
                                <p:column headerText="Paysheet Component ">
                                    <f:facet name="header">
                                        <h:outputLabel value="Paysheet Component"  />
                                    </f:facet>
                                    <p:outputLabel value="#{ss.staffPaysheetComponent.paysheetComponent.name}">
                                    </p:outputLabel>
                                </p:column>  
                                <p:column headerText="Paysheet Component ">
                                    <f:facet name="header">
                                        <h:outputLabel value="ID"  />
                                    </f:facet>
                                    <p:outputLabel value="#{ss.staffPaysheetComponent.id}">
                                    </p:outputLabel>
                                </p:column>  
                                <p:column headerText="Salary Cycle" rendered="#{hrReportController.reportKeyWord.salaryCycle eq null}">
                                    <f:facet name="header">
                                        <h:outputLabel value="Salary Cycle"  />
                                    </f:facet>
                                    <p:outputLabel value="#{ss.salaryCycle.name}">
                                    </p:outputLabel>
                                </p:column>  
                                <p:column headerText="Opennig Balance" rendered="#{hrReportController.reportKeyWord.salaryCycle eq null}">
                                    <f:facet name="header">
                                        <h:outputLabel value="Opennig Balance"  />
                                    </f:facet>
                                    <p:outputLabel value="#{ss.staffPaysheetComponent.startingBalance}">
                                    </p:outputLabel>
                                </p:column>
                                <p:column headerText="Bank">
                                    <f:facet name="header">
                                        <h:outputLabel value="Bank"  />
                                    </f:facet>
                                    <p:outputLabel value="#{ss.staffPaysheetComponent.bankBranch.institution.name}">
                                    </p:outputLabel>
                                </p:column>
                                <p:column headerText="Bank">
                                    <f:facet name="header">
                                        <h:outputLabel value="Bank"  />
                                    </f:facet>
                                    <p:outputLabel value="#{ss.staffPaysheetComponent.id}">
                                    </p:outputLabel>
                                </p:column>
                                <p:column headerText="Component Value " style="text-align: right;">
                                    <f:facet name="header">
                                        <h:outputLabel value="Component Value"  />
                                    </f:facet>
                                    <p:outputLabel value="#{ss.componantValue}">

                                        <f:convertNumber pattern="#,##0.00" />
                                    </p:outputLabel>
                                    <f:facet name="footer">
                                        <p:outputLabel value="#{hrReportController.total}" >
                                            <f:convertNumber pattern="#,##0.00" />
                                        </p:outputLabel>
                                    </f:facet>
                                </p:column>  
                                <p:column headerText="EPF Staff Value " style="text-align: right;">
                                    <f:facet name="header">
                                        <h:outputLabel value="EPF Staff Value"  />
                                    </f:facet>
                                    <p:outputLabel value="#{ss.epfValue}">
                                        <f:convertNumber pattern="#,##0.00" />
                                    </p:outputLabel>
                                </p:column> 
                                <p:column headerText="EPF Company Value " style="text-align: right;">
                                    <f:facet name="header">
                                        <h:outputLabel value="EPF Company Value"  />
                                    </f:facet>
                                    <p:outputLabel value="#{ss.epfCompanyValue}">
                                        <f:convertNumber pattern="#,##0.00" />
                                    </p:outputLabel>
                                </p:column> 
                                <p:column headerText="ETF Company Value " style="text-align: right;">
                                    <f:facet name="header">
                                        <h:outputLabel value="ETF Company Value"  />
                                    </f:facet>
                                    <p:outputLabel value="#{ss.etfCompanyValue}">
                                        <f:convertNumber pattern="#,##0.00" />
                                    </p:outputLabel>
                                </p:column>

                                <p:column headerText="Total" style="text-align: right;">
                                    <f:facet name="header">
                                        <h:outputLabel value="Total"  />
                                    </f:facet>
                                    <p:outputLabel value="#{ss.etfCompanyValue + ss.epfCompanyValue + ss.epfValue + ss.componantValue}">
                                        <f:convertNumber pattern="#,##0.00" />
                                    </p:outputLabel>
                                </p:column>
                                <p:column headerText="Editer" rendered="#{hrReportController.reportKeyWord.bool1}" style="text-wrap: avoid; text-overflow: clip; white-space: nowrap;">
                                    <f:facet name="header">
                                        <h:outputLabel value="Editer"/>
                                    </f:facet>
                                    <p:outputLabel value="#{ss.lastEditor.webUserPerson.name}">
                                    </p:outputLabel>
                                </p:column>
                                <p:column headerText="Comment" rendered="#{hrReportController.reportKeyWord.bool1}" style="text-wrap: avoid; text-overflow: clip; white-space: nowrap;">
                                    <f:facet name="header">
                                        <h:outputLabel value="Comment"/>
                                    </f:facet>
                                    <p:outputLabel value="#{ss.comments}">
                                    </p:outputLabel>
                                </p:column>
                                <p:column headerText="Edited At" rendered="#{hrReportController.reportKeyWord.bool1}">
                                    <f:facet name="header">
                                        <h:outputLabel value="Edited At"/>
                                    </f:facet>
                                    <p:outputLabel value="#{ss.lastEditedAt}">
                                        <f:convertDateTime pattern="yyyy MMM dd" />
                                    </p:outputLabel>
                                </p:column>
                                <f:facet name="footer">
                                    <p:outputLabel value="Print By : #{sessionController.loggedUser.webUserPerson.name} - " />
                                    <p:outputLabel value="Print At : " />
                                    <p:outputLabel value="#{commonController.currentDateTime}" >
                                        <f:convertDateTime pattern="yyyy MMMM dd hh:mm:ss a " />
                                    </p:outputLabel>
                                </f:facet>
                            </p:dataTable>
                        </p:panel>

                        <p:panel rendered="#{hrReportController.reportKeyWord.institutionBank ne null and hrReportController.reportKeyWord.paysheetComponent ne null}" >
                            <p:commandButton value="Print" ajax="false" action="#">
                                <p:printer target="gpBillPreviewPaysheet" ></p:printer>
                            </p:commandButton>
                            <h:panelGroup   id="gpBillPreviewPaysheet">
                                <salary:bank_letter salary="#{hrReportController.staffSalaryComponants}" 
                                                    bank="#{hrReportController.reportKeyWord.institutionBank}" 
                                                    component="#{hrReportController.reportKeyWord.paysheetComponent}"
                                                    total="#{hrReportController.total}"/>
                            </h:panelGroup>
                        </p:panel>


                    </p:panel>

                </h:form>
            </ui:define>

        </ui:composition>

    </h:body>
</html>
